package com.tools.photo.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.github.florent37.glidepalette.GlidePalette;
import com.tools.photo.R;
import com.tools.photo.bean.PhotoUpImageItem;

import java.io.File;
import java.util.List;

/**
 * Created by Administrator on 2016/2/27.
 */
public class MediaAdaptre extends RecyclerView.Adapter<RecyclerView.ViewHolder>{

    Context context;
    List<PhotoUpImageItem> list;

    public MediaAdaptre(Context context,List<PhotoUpImageItem> list) {
        this.context=context;
        this.list=list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v= LayoutInflater.from(context).inflate(R.layout.adapter_media_list_item,parent,false);
        return new MyViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final MyViewHolder holder1=(MyViewHolder)holder;
        File file=new File(list.get(position).getImagePath());
      String url=file.getPath();
     Glide.with(context).load(url).into(holder1.img);
//        holder1.title.setText(file.getName());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class  MyViewHolder extends RecyclerView.ViewHolder{

        ImageView img;
        TextView title;

        public MyViewHolder(View itemView) {
            super(itemView);
            img=(ImageView)itemView.findViewById(R.id.img);
            title=(TextView)itemView.findViewById(R.id.title);
        }
    }
}
